<?php
require_once __DIR__ . '/vendor/autoload.php';

use PhpAmqpLib\Message\AMQPMessage;
use PhpAmqpLib\Connection\AMQPStreamConnection;

$connection = new AMQPStreamConnection('localhost', 5672, 'guest', 'guest', '/');
$channel = $connection->channel();

$channel->exchange_declare('ex01', 'topic', false, false, false);

$msg =new AMQPMessage($argv[2]);
$routeKey = $argv[1];

$channel->basic_publish($msg, 'ex01', $routeKey);
echo "Send Topic Success!\n";

$channel->close();
$connection->close();
